/********************************************
*
*
*
*  test_task.c
*
*
********************************************/


#ifdef __cplusplus
 #if __cplusplus
  extern "C"{
 #endif
#endif /* __cplusplus */


#include "test_suite.h"
#include "d_mem.h"
#include "d_task.h"
#include "d_show.h"
#include "d_queue.h"



VOID UT_CreateTask01(UINT32 ulParam,VOID * pParam)
{
    CU_EQUAL(ulParam , 1234);
    CU_EQUAL(pParam , NULL);
}


UINT32 TEST_DMS_CreateTask_00()
{
    TASK_HANDLE stTask;
    UINT32 ulRet;

    ulRet = DMS_TaskCreate(&stTask,
                           "asdf",
                           UT_CreateTask01,
                           1234,
                           NULL);

    CU_EQUAL(ulRet , DMS_OK);

    DMS_TaskDelay(1000);

    CU_UNEQUAL(DMS_OK, DMS_TaskHandleValid(stTask));

    return DMS_OK;
}

UINT32 TEST_DMS_CreateTask_01()
{

    return DMS_OK;
}


TASK_HANDLE t_taskid[0xff] = {NULL};

VOID UT_001(UINT32 ulParam,VOID * pParam)
{
    CU_EQUAL(ulParam , 234);
    CU_EQUAL(pParam , (VOID *)4321);
}

VOID UT_002(UINT32 ulParam,VOID * pParam)
{
    CU_EQUAL(ulParam , 321);
    CU_EQUAL(pParam , (VOID *)1234);
}


VOID UT_CreateTask02(UINT32 ulParam,VOID * pParam)
{
    UINT32 uil;
    UINT32 ulRet;
    CHAR   acTaskName[DMS_MAX_NAME_LEN];

    for(uil = 0 ; uil < ulParam ; uil++ )
    {
        sprintf(acTaskName,"%s_%d",__FUNCTION__,uil);
        ulRet = DMS_TaskCreate(&t_taskid[uil],
                                acTaskName,
                                UT_001,
                                234,
                                (VOID *)4321);
        CU_EQUAL(ulRet , DMS_OK);
    }

    DMS_TaskDelay(1000);

}

VOID UT_CreateTask03(UINT32 ulParam,VOID * pParam)
{
    UINT32 uil;
    UINT32 ulRet;
    CHAR   acTaskName[DMS_MAX_NAME_LEN];

    for(uil = 0 ; uil < ulParam ; uil++ )
    {
        sprintf(acTaskName,"%s_%d",__FUNCTION__,uil);
        ulRet = DMS_TaskCreate(&t_taskid[uil],
                               acTaskName,
                               UT_002,
                               321,
                               (VOID *)1234);
        CU_EQUAL(ulRet , DMS_OK);
     }

     DMS_TaskDelay(1000);
}

UINT32 TEST_DMS_CreateTask_02()
{
    UINT32 uli;
    TASK_HANDLE ulTaskId_1;
    UINT32 ulRet;

    ulRet = DMS_TaskCreate(&ulTaskId_1,
                           "UT_CreateTask02",
                           UT_CreateTask02,
                           0xff,
                           NULL);
    CU_EQUAL(ulRet , DMS_OK);

    CU_EQUAL(ulRet , DMS_TaskJoin(ulTaskId_1));

    DMS_TaskDelay(1000);

    for(uli = 0 ; uli < 0xff; uli++ )
    {
        CU_UNEQUAL(DMS_OK , DMS_TaskHandleValid(t_taskid[uli]));
    }

    return DMS_OK;
}

UINT32 TEST_DMS_CreateTask_03()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskName_00()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskName_01()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskName_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskName_03()
{

    return DMS_OK;
}

UINT32 TEST_DMS_IsRunTask_00()
{

    return DMS_OK;
}

UINT32 TEST_DMS_IsRunTask_01()
{

    return DMS_OK;
}

UINT32 TEST_DMS_IsRunTask_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_IsRunTask_03()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskID_00()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskID_01()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskID_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetTaskID_03()
{

    return DMS_OK;
}

UINT32 TEST_DMS_DeleteTask_00()
{

    return DMS_OK;
}

UINT32 TEST_DMS_DeleteTask_01()
{

    return DMS_OK;
}

UINT32 TEST_DMS_DeleteTask_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_DeleteTask_03()
{

    return DMS_OK;
}

UINT32 TEST_DMS_WaitTask_00()
{

    return DMS_OK;
}

UINT32 TEST_DMS_WaitTask_01()
{

    return DMS_OK;
}

UINT32 TEST_DMS_WaitTask_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_WaitTask_03()
{

    return DMS_OK;
}

VOID TEST_DMS_CreateTask()
{
    CU_EQUAL(TEST_DMS_CreateTask_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_CreateTask_02(),DMS_OK);
}


VOID TEST_DMS_GetTaskName()
{
    CU_EQUAL(TEST_DMS_GetTaskName_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetTaskName_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetTaskName_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetTaskName_03(),DMS_OK);
}


VOID TEST_DMS_IsRunTask()
{
    CU_EQUAL(TEST_DMS_IsRunTask_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_IsRunTask_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_IsRunTask_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_IsRunTask_03(),DMS_OK);
}


VOID TEST_DMS_GetTaskID()
{
    CU_EQUAL(TEST_DMS_GetTaskID_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetTaskID_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetTaskID_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetTaskID_03(),DMS_OK);
}


VOID TEST_DMS_DeleteTask()
{
    CU_EQUAL(TEST_DMS_DeleteTask_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_DeleteTask_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_DeleteTask_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_DeleteTask_03(),DMS_OK);
}


VOID TEST_DMS_WaitTask()
{
    CU_EQUAL(TEST_DMS_WaitTask_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_WaitTask_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_WaitTask_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_WaitTask_03(),DMS_OK);
}

VOID TEST_suite_task(VOID)
{
    CU_pSuite suite;
    suite = CU_add_suite(__FUNCTION__, NULL, NULL);
    CU_ADD_TEST(suite, TEST_DMS_CreateTask);
    CU_ADD_TEST(suite, TEST_DMS_GetTaskName);
    CU_ADD_TEST(suite, TEST_DMS_IsRunTask);
    CU_ADD_TEST(suite, TEST_DMS_GetTaskID);
    CU_ADD_TEST(suite, TEST_DMS_DeleteTask);
    CU_ADD_TEST(suite, TEST_DMS_WaitTask);
}

#ifdef __cplusplus
 #if __cplusplus
  }
 #endif
#endif /* __cplusplus */
